/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine - graphics/renderer/renderstates
// Copyright (c) 2015.  All Rights Reserved
//
// File:		AEStateGroupRasterizer.h
// Author:		Gianluca Belardelli
// Date:		17/07/2015
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AESTATEGROUPRASTERIZER_H_
#define _AESTATEGROUPRASTERIZER_H_

/// \brief
///   All available rasterizer style types for surfaces/primitives
enum AERasterizerStyle 
{
	AERASTERIZER_CULL_FRONT = 0,
	AERASTERIZER_CULL_BACK = 1,
	AERASTERIZER_CULL_NONE = 2,
	AERASTERIZER_SCISSOR_BIT = 4, ///< bit flag that can be combined with all other modes 
	AERASTERIZER_CULL_FRONT_SCISSOR = 4,
	AERASTERIZER_CULL_BACK_SCISSOR = 5,
	AERASTERIZER_CULL_NONE_SCISSOR = 6,
	AERASTERIZER_WIREFRAME = 7,
	AERASTERIZER_NO_MULTISAMPLE_BIT = 8 ///< bit flag that can be combined with all other modes 
};
/// \brief
///   State group that controls the rasterization properties
///
/// Note that not all states which are part of this state group are actually supported by all platforms. Please
/// refer to each platform's graphics documentation for information on which render states the hardware and graphics API
/// of that platform support.
class AEStateGroupRasterizer
{
// Members
public:
	AEUINT8		m_ucFillMode;            ///< Fill mode. One of the members of the AEFillMode enumeration.
	AEUINT8		m_ucCullMode;            ///< Cull mode. One of the members of the AECullMode enumeration.
	AEFLOAT32	m_fDepthBias;            ///< Depth Bias
	AEFLOAT32	m_fDepthBiasClamp;       ///< Depth Bias Clamp
	AEFLOAT32	m_fSlopeScaledDepthBias; ///< Slope-scaled Depth Bias
	AEUINT8		m_ucFlags;               ///< Bits: 1=FrontCounterClockwise, 2=DepthClipDisable, 4=ScissorEnable, 8=MultisamplingEnable
	AEUINT32	m_uiHash;

// Methods
public:
	AE_FORCEINLINE AEStateGroupRasterizer( void );

	/// \brief
	///   Assignment operator
	AE_FORCEINLINE AEStateGroupRasterizer& operator = ( const AEStateGroupRasterizer &other );

	/// \brief
	///   Comparison operator
	AE_FORCEINLINE bool operator == ( const AEStateGroupRasterizer &other ) const;

	/// \brief
	///   Comparison operator
	AE_FORCEINLINE bool operator != ( const AEStateGroupRasterizer &other ) const;

	/// \brief
	///   Computes the hash value for this state group. This function has to be called prior to using the state group.
	///
	/// This function always has to be called after setting up a new state group or after modifying an existing state group.
	/// It computes a hash which is internally used for optimization purposes, and additionally generates platforms-specific
	/// data which is critical to the use of the state group.
	AE_DLLIMPEXP void ComputeHash( void );

	/// \brief
	///   Invalidates all states (for internal use)
	AE_DLLIMPEXP void Invalidate( void );

	AE_DLLIMPEXP AEBOOL32 IsHashValid( void ) const;
};

#include "AEStateGroupRasterizer.inl"

#endif // _AESTATEGROUPRASTERIZER_H_
